<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>历史搜索</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        h3 {
            margin-top: 20px;
        }

        .jiantou {
            color: deepskyblue;
            font-size: 24px;
        }

        .search input {
            background-color: rgb(241, 237, 237);
            border-radius: 20px;
            border: none;
            padding: 10px 30px;
            width: 260px;
            margin-left: 10px;
            margin-top: 20px;
        }

        .search span {
            color: deepskyblue;
            margin-left: 10px;
        }

        .history,
        .find {
            box-sizing: border-box;
            padding: 0 10px;
            
        }
        
        .find{
            margin-top: 30px;
        }
        .history .htop {
            display: flex;
            justify-content: space-between;
            padding: 15px 0;
        }
        .history .item {
            font-size: 12px;
            display: inline-block;
            height: 25px;
            line-height: 25px;
            padding: 0 10px;
            margin-top: 5px;
            margin-right: 5px;
            background-color: rgb(223, 223, 223);
        }

        

        .find .item {
            font-size: 12px;
            display: inline-block;
            height: 25px;
            line-height: 25px;
            margin-right: 5px;
            padding: 0 10px;
            margin-top: 5px;
            background-color: rgb(223, 223, 223);
        }
    </style>
</head>

<body>
    <div id="app">
        <h3> <span class="jiantou">< </span> 搜索</h3>
        <div class="search">
            <input type="text" placeholder="搜索商家，商品名称" v-model="inputText">
            <span @click="add()">搜索</span>
        </div>
        <div class="history">
            <div class="htop">
                <h5>历史搜索</h5>
                <span class="clear" @click="clear()">删除</span>
            </div>
            <span class="item" v-for="(item,index) in historyList">{{item}}</span>
        </div>
        <div class="find">
            <h5>搜索发现</h5>
            <span class="item" v-for="(item,index) in findList">{{item}}</span>
        </div>
    </div>
</body>

</html>
<script src="../js/vue-2.5.21.js"></script>
<script>
    var v = new Vue({
        el: '#app',
        data: {
            inputText:'',
            historyList:['天天鲜挪威三文鱼(立水桥店)'],
            findList:['麻辣烫','米线','披萨','蛋糕','汉堡','腊八粥','烤肉拌饭','炸鸡']
        },
        methods:{
            add(){
                if(this.inputText){
                    this.historyList.push(this.inputText)
                    this.inputText=''
                }
            },
            clear(){
                this.historyList=[]
            }
        }
    })
</script>